<template>
  <div class="biddingBox">
    <div class="timeBox" v-if="detailsTag != 'mentioned'">
      <div class="time" v-if="$route.name == 'new_auction_Bidding_detail'">参拍时间：{{ infoData.created_at }}</div>
      <div class="time" v-if="$route.name == 'new_auction_Auction_details'">委拍时间：{{ infoData.created_at }}</div>
      <div class="statusBox" v-if="$route.name == 'new_auction_Bidding_detail'">{{ infoData.status_name }}</div>
      <div class="statusBox" v-if="$route.name == 'new_auction_Auction_details'">{{ infoData.reward_status == 0 ? "委拍中" : "委拍成功" }}</div>
      <div class="time" v-if="detailsTag == 'bidding' || detailsTag == 'auction'" style="font-size: 0.81rem; color: #8f8f8f">
        {{ detailsTag == "bidding" ? "委拍时间" : "参拍时间" }}：{{ infoData.created_at }}
      </div>
      <div class="statusBox" v-if="detailsTag == 'auction'" style="color: #fe8f00; font-size: 0.88rem">{{ infoData.status_name }}</div>
      <div class="statusBox" v-if="detailsTag == 'bidding'" style="color: #fe8f00; font-size: 0.88rem">{{ infoData.reward_status == 0 ? "委拍中" : "委拍成功" }}</div>
      <div class="time" v-if="detailsTag == 'Readmentioned' || detailsTag == 'usable'" style="font-size: 0.81rem; color: #8f8f8f">
        {{ detailsTag == "Readmentioned" ? "订单时间" : "参拍时间" }}：{{ detailsTag == "Readmentioned" ? infoData.create_time : infoData.created_at }}
      </div>
      <div class="statusBox" v-if="detailsTag == 'Readmentioned' || detailsTag == 'usable'" style="color: #fe8f00; font-size: 0.88rem">{{ infoData.status_name }}</div>
    </div>
    <div class="good">
      <div class="good_l">
        <img :src="infoData.thumb" alt="" v-if="detailsTag == 'mentioned'" />
        <img :src="infoData.has_one_order_goods.thumb" alt="" v-if="detailsTag == 'Readmentioned' && infoData.has_one_order_goods" />
        <img :src="infoData.has_one_goods.thumb" alt="" v-if="(detailsTag == 'bidding' || detailsTag == 'auction' || detailsTag == 'usable') && infoData.has_one_goods" />
        <img :src="infoData.has_one_goods.thumb" alt="" v-if="infoData.has_one_goods && !detailsTag" />
      </div>
      <div class="good_r" v-if="$route.name == 'new_auction_Bidding_detail'">
        <div class="good_r_title van-ellipsis" v-if="infoData.has_one_goods">{{ infoData.has_one_goods.title }}</div>
        <div class="good_r_b">
          <div class="num"><span class="txt">拍品个数：</span>{{ infoData.show_count }}</div>
          <div class="price"><span class="txt">拍品价格：</span>{{ $i18n.t("money") }}{{ infoData.once_amount }}</div>
          <div class="lotValue"><span class="txt">拍品价值：</span>{{ $i18n.t("money") }}{{ infoData.amount }}</div>
        </div>
      </div>
      <div class="good_r" v-if="$route.name == 'new_auction_Auction_details'">
        <div class="good_r_title van-ellipsis" v-if="infoData.has_one_goods">{{ infoData.has_one_goods.title }}</div>
        <div class="good_r_b">
          <div class="num"><span class="txt">拍品个数：</span>{{ infoData.goods_count }}</div>
          <div class="price"><span class="txt">拍品价格：</span>{{ $i18n.t("money") }}{{ infoData.before_amount }}</div>
          <div class="lotValue"><span class="txt">拍品价值：</span>{{ $i18n.t("money") }}{{ infoData.after_amount }}</div>
        </div>
      </div>
      <!-- 参拍/委拍明细 -->
      <div class="good_r" v-if="detailsTag == 'auction' || detailsTag == 'bidding'">
        <div
          class="good_r_title"
          style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; text-overflow: ellipsis; white-space: pre-wrap"
          v-if="infoData.has_one_goods"
        >
          {{ infoData.has_one_goods.title }}
        </div>
        <div class="good_r_b" style="font-size: 0.81rem; color: #6a6a6a">
          <div class="num"><span class="txt">商品总价值：</span>{{ $i18n.t("money") }}{{ detailsTag == "bidding" ? infoData.after_amount : infoData.amount }}</div>
          <div class="num"><span class="txt">商品数量：</span>{{ detailsTag == "bidding" ? infoData.goods_count : infoData.show_count }}</div>
        </div>
      </div>
      <!-- 我的仓库 待提，已提，正在参拍 -->
      <div class="good_r" v-if="detailsTag == 'mentioned' || detailsTag == 'Readmentioned' || detailsTag == 'usable'">
        <div class="good_r_titleMd" v-if="detailsTag == 'mentioned'">{{ infoData.title }}</div>
        <div class="good_r_titleMd" v-if="detailsTag == 'Readmentioned' && infoData.has_one_order_goods">{{ infoData.has_one_order_goods.title }}</div>
        <div class="good_r_titleMd" v-if="detailsTag == 'usable' && infoData.has_one_goods">{{ infoData.has_one_goods.title }}</div>
        <div class="good_r_bottom">
          <div class="good_r_b" style="font-size: 0.81rem; color: #6a6a6a" v-if="detailsTag == 'mentioned' || detailsTag == 'Readmentioned'">
            <div class="num"><span class="txt">提货价格: </span>{{ $i18n.t("money") }}{{ detailsTag == "mentioned" ? infoData.max_amount : infoData.goods_once_price }}</div>
            <div class="num"><span class="txt">库存数量: </span>{{ infoData.stock }}</div>
          </div>
          <div class="good_r_b" style="font-size: 0.81rem; color: #6a6a6a" v-if="detailsTag == 'usable'">
            <div class="num"><span class="txt">持有量: </span>{{ infoData.show_count }}</div>
            <div class="price"><span class="txt">拍品价格：</span>{{ $i18n.t("money") }}{{ infoData.once_amount }}</div>
            <div class="lotValue"><span class="txt">拍品价值：</span>{{ $i18n.t("money") }}{{ infoData.amount }}</div>
          </div>
          <div class="btn_pickup" v-if="detailsTag == 'mentioned'" @click="pickUp_mentioned()">提货</div>
        </div>
      </div>
    </div>
    <div class="btn" v-if="$route.name == 'new_auction_Bidding_detail'">
      <div class="cancel" v-if="infoData.settle_count" @click.stop="settle_handle">结算</div>
      <div class="cancel" v-if="infoData.status == 0" @click.stop="cancelAuction">取消参拍</div>
      <div class="cancel" @click.stop="pickUp" v-if="infoData.usable_count">提货</div>
    </div>
    <div class="btn" v-if="detailsTag == 'auction'">
      <div class="cancel" v-if="infoData.status == 0" @click.stop="cancelAuction">取消参拍</div>
    </div>
    <div class="btn" v-if="detailsTag == 'Readmentioned' || detailsTag == 'usable'">
      <div class="totalPrice" v-if="detailsTag == 'Readmentioned'"><span>提货总价:</span>{{ $i18n.t("money") }}{{ infoData.goods_price }}</div>
      <template v-if="detailsTag == 'usable'">
        <div class="cancel" @click.stop="pickUp" v-if="infoData.usable_count">购买拍品</div>
        <div class="cancel green" v-if="infoData.settle_count" @click.stop="settle_handle">结算</div>
      </template>
    </div>
  </div>
</template>
<script>
export default {
  props: ["infoData", "detailsTag"],
  data() {
    return {};
  },
  computed: {
    deliveryPrice() {
      if (this.detailsTag == "mentioned") {
        return this.infoData.max_amount;
      } else if (this.detailsTag == "Readmentioned") {
        return this.infoData.goods_once_price;
      }
    }
  },
  methods: {
    settle_handle() {
      this.$emit("settle_handle", { id: this.infoData.id, data: this.infoData });
    },
    pickUp() {
      this.$emit("pickUp", { id: this.infoData.id, item: this.infoData });
    },
    cancelAuction() {
      this.$emit("cancelAuction", { id: this.infoData.id });
    },
    pickUp_mentioned(item) {
      if (this.infoData.stock == 0) {
        this.$toast("库存不足");
        return;
      }
      this.$emit("pickUp_new", { id: this.infoData.activity_id, item: this.infoData });
    }
  }
};
</script>
<style lang="scss" scoped>
.biddingBox {
  margin: 0.63rem 0.78rem;
  padding: 0.97rem 0.69rem;
  box-sizing: border-box;
  background: #fff;
  border-radius: 0.5rem;
  .timeBox {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.97rem;
    .time {
      font-size: 0.81rem;
      color: #9898a1;
    }
    .statusBox {
      font-size: 0.81rem;
      color: #f15353;
    }
  }
  .btn {
    margin-top: 0.63rem;
    display: flex;
    justify-content: flex-end;
    .cancel {
      width: 4.69rem;
      border-radius: 1.88rem;
      border: 0.03rem solid #aaaab3;
      text-align: center;
      font-size: 0.94rem;
      margin-left: 0.63rem;
      padding: 0.23rem 0.3rem;
      box-sizing: border-box;
    }
    .green {
      background: #126f46;
      color: #fff;
      font-weight: bold;
      font-size: 0.94rem;
    }
    .totalPrice {
      font-weight: bold;
      font-size: 0.88rem;
      display: flex;
      align-items: center;
      span {
        font-weight: 400;
        font-size: 0.88rem;
        color: #000000;
        margin-right: 0.38rem;
      }
    }
  }
  .good {
    display: flex;
    justify-content: space-between;

    .good_r {
      flex: 1;
      overflow: hidden;
      text-align: left;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .good_r_title {
        font-weight: 500;
        font-size: 0.88rem;
      }
      .good_r_titleMd {
        font-weight: bold;
        font-size: 0.88rem;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: pre-wrap;
      }
      .good_r_bottom {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        .btn_pickup {
          font-weight: bold;
          font-size: 0.94rem;
          color: #ffffff;
          width: 4.69rem;
          height: 1.75rem;
          background: #126f46;
          border-radius: 0.84rem;
          text-align: center;
          line-height: 1.75rem;
        }
      }
      .good_r_b {
        font-weight: 500;
        font-size: 0.81rem;
        .txt {
          color: #6e6e79;
        }
      }
    }
    .good_l {
      flex-shrink: 0;
      width: 5.38rem;
      height: 5.38rem;
      background: #d6d6dc;
      border-radius: 0.63rem;
      margin-right: 0.53rem;
      img {
        width: 100%;
        height: 100%;
        border-radius: 0.63rem;
      }
    }
  }
}
</style>
